package com.softer.wxzj.controller;


import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.common.util.ShiroUserUtil;
import com.softer.wxzj.entity.FlowType;
import com.softer.wxzj.service.FlowTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * FlowTypeController class
 * @author zcz
 * @date 2019/4/10
 */
@RestController
@RequestMapping("/flowType")
@Slf4j
public class FlowTypeController {
    @Autowired
    FlowTypeService flowTypeService;

    @RequestMapping("/add")
    @LogRecord(description = "审批流程类型添加",operationUnit = LogOperationUnit.FLOW_TYPE,operationType = LogOperationType.INSERT)
    public CommonResult add(FlowType f) {
        f.setCreater(ShiroUserUtil.getUserName());
        return flowTypeService.insert(f);
    }
    @RequestMapping("/update")
    @LogRecord(description = "审批流程类型列表修改",operationUnit = LogOperationUnit.FLOW_TYPE,operationType = LogOperationType.UPDATE)
    public CommonResult update(FlowType f) {
        return flowTypeService.update(f);
    }
    @RequestMapping("/delete")
    @LogRecord(description = "审批流程类型删除",operationUnit = LogOperationUnit.FLOW_TYPE,operationType = LogOperationType.DELETE)
    public CommonResult delete(String id) {
        return flowTypeService.delete(id);
    }
    @RequestMapping("/getList")
    @LogRecord(description = "审批流程类型列表查询",operationUnit = LogOperationUnit.FLOW_TYPE,operationType = LogOperationType.SELECT)
    public PageInfo<FlowType> getList(Page page, FlowType f) {
        return flowTypeService.getList(page,f);
    }
    @RequestMapping("/getInfo")
    @LogRecord(description = "查询审批流程类型详情",operationUnit = LogOperationUnit.FLOW_TYPE,operationType = LogOperationType.SELECT)
    public FlowType getInfo(String id){
        return flowTypeService.getInfo(id);
    }



}
